package com.example.exam.MeunFrgment;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.example.exam.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ZhangFH extends Fragment {


    @BindView(R.id.iv_tp)
    ImageView ivTp;
    @BindView(R.id.bu_ggtp)
    Button buGgtp;
    @BindView(R.id.pb_jdt)
    ProgressBar pbJdt;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_zhang_fh, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        Glide.with(getActivity()).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575043824400&di=b16380af7d04bce285df02e4fbb4b7d9&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180905%2F43efcaebe81b4b888c06a2c20a6d8cd3.gif").into(ivTp);
    }

    @OnClick(R.id.bu_ggtp)
    public void onViewClicked() {
        //设置对话框
        AlertDialog.Builder dialog=new AlertDialog.Builder(getContext());
        dialog.setTitle("This is Dialog");
        dialog.setMessage("Something important(重要的事情)");
        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Toast.makeText(getContext(), "点击了确认", Toast.LENGTH_SHORT).show();
            }
        });
        dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Toast.makeText(getContext(), "点击了取消", Toast.LENGTH_SHORT).show();
            }
        });
        dialog.show();
        ivTp.setImageResource(R.drawable.bg);
        if (pbJdt.getVisibility()==View.GONE){
            pbJdt.setVisibility(View.VISIBLE);
        }else {
            pbJdt.setVisibility(View.GONE);
        }
    }

    @OnClick(R.id.pb_jdt)
    public void onViewClicked1() {
        Toast.makeText(getContext(), "我是进度条", Toast.LENGTH_SHORT).show();
    }
}
